# Maintainer: Torsten Keßler <tpkessler at archlinux dot org>
# Contributor: Jingbei Li <i@jingbei.li>

pkgname=intel-oneapi-dpcpp-debugger
_pkgver=2023.0.0
_debpkgrel=25336
pkgver=${_pkgver}_${_debpkgrel}
pkgrel=2
pkgdesc='Intel OneAPI GDB'
arch=('loong64' 'x86_64')
url='https://software.intel.com/content/www/us/en/develop/tools/oneapi.html'
license=("custom")
source=("https://apt.repos.intel.com/oneapi/pool/main/${pkgname}-${_pkgver}-${_pkgver}-${_debpkgrel}_amd64.deb"
        "https://apt.repos.intel.com/oneapi/pool/main/${pkgname}-eclipse-cfg-${_pkgver}-${_debpkgrel}_all.deb")
b2sums=('4d03f95f7d1e166f00e760cb5112dd4b43d9b4c3678f7064e164837e60b9bdc2854e5a542d7ac4e88b7235ce509414900fe2211c9270bda4a697a20018f22fce'
        '4f700be803a90c3807d986b477d83aa42680ccd4db0b16c8d45e491b67d5188549aabdc7e4597bac8824b80cdabb2af929b769c9356026e704f0d7bf437bc2c2')
noextract=(
	"${pkgname}-${_pkgver}-${_pkgver}-${_debpkgrel}_amd64.deb"
	"${pkgname}-eclipse-cfg-${_pkgver}-${_debpkgrel}_all.deb"
)
depends=('intel-oneapi-common')
provides=("$pkgname-eclipse-cfg")
conflicts=('intel-oneapi-basekit')

package() {
    cd "${srcdir}"
    ar x "${srcdir}/${pkgname}-${_pkgver}-${_pkgver}-${_debpkgrel}_amd64.deb"
    tar xvf data.tar.xz -C "${pkgdir}"
    rm data.tar.xz

    ar x "${srcdir}/${pkgname}-eclipse-cfg-${_pkgver}-${_debpkgrel}_all.deb"
    tar xvf data.tar.xz -C "${pkgdir}"
    rm data.tar.xz

    local _deb_path='/opt/intel/oneapi/debugger/'
    ln -s "${_deb_path}/${_pkgver}" "${pkgdir}/${_deb_path}/latest"
    # Allow libs to be found
    local _lib_path='/opt/intel/oneapi/debugger'
    local _ldso_conf="${pkgdir}"/etc/ld.so.conf.d
    install -d "${_ldso_conf}"
    echo "${_lib_path}/latest/gdb/intel64/lib" > "${_ldso_conf}/${pkgname}.conf"

    install -d "${pkgdir}"/usr/share/licenses/"${pkgname}"
    ln -s /usr/share/licenses/intel-oneapi "${pkgdir}"/usr/share/licenses/"${pkgname}"/oneapi
}
